const Koa = require('koa');
const cors=require('koa2-cors');
const json = require('koa-json');
const routerIndex =require('./routers/index.js');
const render = require('koa-ejs');
const bodyparser = require('koa-bodyparser');
const path = require('path');
// const ModelDb = require('./db')

const app = new Koa();


app.use(json());
app.use(bodyparser());
app.use(cors());
// router.get('/test',ctx=>(ctx.body ="hello router"))
// DB

// 配置路由
app.use(routerIndex.routes()).use(routerIndex.allowedMethods());
// 配置模板引擎
render(app, {
    root: path.join(__dirname, 'views'),
    layout: 'layout',
    viewExt: 'html',
    cache: false,
    debug: false
});


app.listen(80, () => console.log("server port 80"));